<template>
    <div>
         <el-table  v-loading="loading" :data="tableData" border style="width: 100%">
            

               <template v-for="(item,index) in tableTitle" >
                    <!-- <el-table-column :width="item.width" v-if="item.prop == 'member_info.gender'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                            <div >{{ $baseBai['gender'][scope.row.member_info.gender] }}</div>
                        </template>
                      </el-table-column>

                      <el-table-column :width="item.width" v-else-if="item.prop == 'status'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                            <span class="on">{{ $baseBai['mzsf']['gh_zt'][scope.row.status-1].label }}</span>
                        </template>
                      </el-table-column>
 -->
                      <el-table-column :width="item.width" v-if="item.prop == 'status'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                            <span class="on" v-if="scope.row.status==1">已执行</span>
                            <span class="on" v-if="scope.row.status==2">未执行</span>
                        </template>
                      </el-table-column>
                       <el-table-column :width="item.width" v-else-if="item.prop == 'usage'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                          <span v-if="scope.row.usage">
                            <span class="on"  v-if="!isNaN(scope.row.usage)" >{{ (thatF.geiyao.find(res=>res.id==scope.row.usage))['name'] }}</span>
                          </span>
                            
                         
                        </template>
                      </el-table-column>
                        <el-table-column :width="item.width" v-else-if="item.prop == 'dose'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                            <span>{{ scope.row.num+''+ scope.row.dose_unit }}</span>
                         
                        </template>
                      </el-table-column>

                       <el-table-column :width="item.width" v-else-if="item.prop == 'each_dos'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                          <span v-if="scope.row.each_dos">
                             <span  v-if="!isNaN(scope.row.each_dos)" >{{ (thatF.pinci.find(res=>res.id==scope.row.each_dos))['name'] }}</span>
                          </span>
                           
                         
                        </template>
                      </el-table-column>
                      <el-table-column :width="item.width" v-else-if="item.prop == 'is_skin_test'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                            <!-- <span   v-if="scope.row.is_skin_test==1&&scope.row.skin_test_result==3">需要</span> -->
                            <span   v-if="scope.row.is_skin_test==1&&(scope.row.skin_test_result==1)" style="color:red" @click="openPiShi(scope.row)">阴性</span>
                            <span  v-else-if="scope.row.is_skin_test==1&&(scope.row.skin_test_result==2)"  style="color:red"  @click="openPiShi(scope.row)">阳性</span>
                         
                           <!-- <span  v-else-if="scope.row.is_skin_test==2">不需要</span> -->
                        </template>
                      </el-table-column>
                    
                       <el-table-column :width="item.width" v-else-if="item.prop == 'trans_speed'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                          <span v-if="scope.row.trans_speed">
                             <span  v-if="!isNaN(scope.row.trans_speed)" >{{ (thatF.disu.find(res=>res.id==scope.row.trans_speed))['name'] }}</span>
                          </span>
                           
                         
                        </template>
                      </el-table-column>
                           <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'diagnosis'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span v-if="scope.row.diagnosis">
                    
                        <span  v-for="(item,diag_index) in scope.row.diagnosis">
                          {{item.name}}
                        </span>
                    </span>
                  </template>
                </el-table-column> 

                      <el-table-column v-else :width="item.width":prop="item.prop" :label="item.label" :key="index"> </el-table-column>
               </template>
            <el-table-column label="操作" width="150" fixed="right"    v-if="thatF.activeName!='three'" >
              <template slot-scope="scope">
                <el-dropdown
                  class="tableMore"
                  split-button
                  v-if="thatF.activeName=='one'"
                  type="primary"
                  size="12"
                  @command="handleClick"
                
                >
                  更多
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item :command="scope.row" type="1" >划价</el-dropdown-item>
                    <el-dropdown-item :command="scope.row" type="2" >执行</el-dropdown-item>
                    <el-dropdown-item :command="scope.row" type="3" v-if="scope.row.is_skin_test==1">皮试</el-dropdown-item>
                    <el-dropdown-item :command="scope.row" type="4" disabled>打印预览</el-dropdown-item>
                    <el-dropdown-item :command="scope.row" type="5" disabled>打印</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
                <div  v-if="thatF.activeName=='two'">
                    <el-button type="success"  @click="sub(scope.row)">完成</el-button>
                </div>
                
              </template>
            </el-table-column>
          </el-table>
    </div>
</template>

<script>
import { Switch } from 'element-ui'
export default {
   props:['tableTitle','tableData','loading','thatF'],
    data() {
        return {
            
        }
    },
    methods:{
      more(item){
        console.log("item",item)
      },
      sub(){
        console.log('完成')
      },
      openPiShi(item){
          this.thatF.skinTestData=item;
          this.thatF.getClinic_nurseGetSkinTestHistory(item.id)
          this.thatF.skinTest_status=2;
            this.thatF.show_skinTestSave=true;
      },
      handleClick(...item){
       
          
          switch (item[1].$attrs.type) {
            case '1':
                  //  this.$emit('dialogStatus');
              break;
            case '2':
              
                  // if(item[0].status>1){
                  //   return this.$message('已开立处方，不允许退号' );
                  // }
              break;
              case '3':
                console.log(item)
                if(item[0].is_skin_test==1){
                   this.thatF.skinTestData=item[0]
                  this.thatF.show_skinTestSave=true;
                    this.thatF.skinTest_status=1;

                      this.thatF.getClinic_nurseGetSkinTestHistory(item[0].id)
                } else if(item[0].is_skin_test==2){
                    return this.$message('该条信息不需要皮试' );
                }
               
              break;
             
          
            default:
              break;
          }
      },
    },

}
</script>
<style lang='scss' scoped>


// /deep/ .el-table td, .el-table th.is-leaf{
//    text-align: center;
// }
  
.tableMore {
  /deep/ .el-button--primary {
    color: black;
    background-color: initial;
    border-color: #e2e2e2;
  }
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.on{
      display: inline-block;
    background: #3cad83;
    padding: 0px 10px;
    border-radius: 3px;
    font-size: 12px;
    color: white;
}
</style>